﻿<UserControl x:Class="AppFabric.Admin.Clients.Desktop.UserControls.EnvironmentManagementUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:lex="clr-namespace:WPFLocalizeExtension.Extensions;assembly=WPFLocalizeExtension"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
             xmlns:data="clr-namespace:AppFabric.Admin.Clients.Common.Data;assembly=AppFabric.Admin.Clients.Common"
             xmlns:vm="clr-namespace:AppFabric.Admin.Clients.Desktop.ViewModel"
             xmlns:converters="http://schemas.kent.boogaart.com/converters"
             xmlns:myconverters="clr-namespace:AppFabric.Admin.Clients.Desktop.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="700">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <DataTemplate x:Key="EnvironmentComboBoxDataTemplate" DataType="vm:EnvironmentViewModel">
                <WrapPanel Height="40">
                    <Image Source="/Skins/environment.ico" />
                    <StackPanel Margin="10 0 10 0">
                        <TextBlock Text="{Binding Name}" Style="{StaticResource BackStageEnvironmentNameStyle}" />
                        <TextBlock Text="{Binding Description}" Style="{StaticResource BackStageEnvironmentDescriptionStyle}" />
                    </StackPanel>
                </WrapPanel>
            </DataTemplate>

            <Style x:Key="EnvironmentComboxBoxStyle" TargetType="{x:Type ComboBox}">
                <Setter Property="Height" Value="48" />
                <Setter Property="Width" Value="370" />
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="BorderBrush" Value="DarkGray" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Environments.Count, Converter={converters:ExpressionConverter {}{0} > 0}}" Value="True">
                        <Setter Property="SelectedIndex" Value="0" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="EnvironmentsManagementUCGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions> 
        <StackPanel Grid.Column="0" Grid.Row="0">
            <TextBlock Text="{lex:LocText Key=EnvironmentsHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Style="{StaticResource BackStageTextBlockLevel2Title}" />
            <StackPanel Orientation="Horizontal">
                <StackPanel>
                    <Button x:Name="AddEnvironmentButton" Style="{StaticResource BackStageImageButton24x24Style}" Command="{Binding AddEnvironmentCommand, Mode=OneWay}">
                        <Image Source="/Skins/add.png" />
                    </Button>
                    <Button x:Name="RemoveEnvironmentButton" Style="{StaticResource BackStageImageButton24x24Style}" Command="{Binding RemoveEnvironmentCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=EnvironmentsComboBox, Path=SelectedIndex}">
                        <Image Source="/Skins/remove.png" />
                    </Button>
                </StackPanel>
                <ComboBox x:Name="EnvironmentsComboBox"
                      ItemsSource="{Binding Environments}"
                      ItemTemplate="{StaticResource EnvironmentComboBoxDataTemplate}"
                      Style="{StaticResource EnvironmentComboxBoxStyle}">
                </ComboBox>
            </StackPanel>
        </StackPanel>
        <Grid Grid.Column="0" Grid.Row="1" Style="{StaticResource BackStageEnvironmentPropertiesStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="75" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Text="{lex:LocText Key=EnvironmentName, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Style="{StaticResource BackstageLabelStyle}" />
            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name, Mode=TwoWay}" Style="{StaticResource BackstageTextBoxStyle}"  />
            <TextBlock Grid.Row="1" Grid.Column="0"  Text="{lex:LocText Key=EnvironmentDescription, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Style="{StaticResource BackstageLabelStyle}"/>
            <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Description, Mode=TwoWay}" Style="{StaticResource BackstageTextBoxStyle}" />
            <TextBlock Grid.Row="2" Grid.Column="0"  Text="{lex:LocText Key=EnvironmentClusters, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Style="{StaticResource BackstageLabelStyle}"/>
            <StackPanel  Grid.Row="3" Grid.Column="0" Style="{StaticResource BackStageStackPanelClusterButtonStyle}">
                <Button Style="{StaticResource BackStageImageButton24x24Style}" Command="{Binding AddClusterCommand, Mode=OneWay}">
                    <Image Source="/Skins/add.png" />
                </Button>
                <Button Style="{StaticResource BackStageImageButton24x24Style}" Command="{Binding RemoveClusterCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=EnvironmentClustersDataGrid, Path=SelectedIndex}">
                    <Image Source="/Skins/remove.png" />
                </Button>
            </StackPanel>
            <DataGrid x:Name="EnvironmentClustersDataGrid" Grid.Row="3" Grid.Column="1"
                      ItemsSource="{Binding Children, Mode=TwoWay}"
                      RowStyle="{StaticResource BackStageDataGridRowStyle}"
                      Style="{StaticResource BackStageDataGridStyle}">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="{lex:LocText Key=HeaderClusterName, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Binding="{Binding Name}" MinWidth="90" />
                    <DataGridTextColumn Header="{lex:LocText Key=HeaderClusterUri, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Binding="{Binding Uri}" MinWidth="217"  />
                    <DataGridTextColumn Header="{lex:LocText Key=HeaderClusterUserName, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" Binding="{Binding UserName}" MinWidth="120"  />
                    <DataGridTemplateColumn Header="{lex:LocText Key=HeaderClusterUserPassword, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" MinWidth="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <PasswordBox myconverters:PasswordHelper.Attach="True" myconverters:PasswordHelper.Password="{Binding UserPassword, Mode=TwoWay}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
        <Grid x:Name="ClustersServiceSate" Grid.Column="1" Grid.Row="1">
            
        </Grid>
    </Grid>
</UserControl>
